#include<iostream>
using namespace std;
#include"TreeNode.h"

class solution1
{
public:
	bool isSymeric(TreeNode* head)
	{
		if (head == nullptr)
		{
			return true;
		}
		return process(head->left,head->right);
	}
	bool process(TreeNode* left,TreeNode*right)
	{
		if (left == nullptr && right == nullptr)
		{
			return true;
		}
		if (left == nullptr ||right == nullptr)
		{
			return false;
		}
		return (left->val == right->val && process(left->left, right->right) && process(left->right, right->left));
	}
};




void main()
{
	solution s;
	vector<int>vec{ 1,2,3,4,5,6,7 };
	TreeNode* head = s.GenerateTree(vec);
	s.preOrder(head);

	solution1 ss;
	cout<<ss.isSymeric(head);

	system("pause");
	return;
}